{{csrf_field()}}
<fieldset class="layui-elem-field">
    <legend>编辑商品</legend>
    <div class="layui-field-box">

<div class="layui-form-item layui-col-md6">
    <label for="" class="layui-form-label">商品名称</label>
    <div class="layui-input-block">
        <input type="text" name="goods_name" value="{{ $goods->goods_name ?? '' }}" lay-verify="required"  class="layui-input" >
    </div>
</div>
<div class="layui-col-md6">
    <label for="" class="layui-form-label">缩略图</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <div class="layui-upload-list">
                <img class="layui-upload-img" id="uploadPhoto-img" width="80" height="80" src="{{$goods->photo ?? 'http://ccvs-oss.oss-cn-hangzhou.aliyuncs.com/goods/d7NzLMLVweSouv7VZ0mByYjI2fTShEWrjFQUugnC.png' }}">
                <p id="test-upload-demoText"></p>
            </div>
            <button type="button" class="layui-btn" id="uploadPhoto"  >上传图片</button>
            <input type="hidden" id="photo" name="photo" type="text"  value="{{$goods->photo ?? ''}}" >
        </div>
    </div>
</div>
<div class="layui-form-item layui-col-md6">
    <label for="" class="layui-form-label">商品简称</label>
    <div class="layui-input-block">
        <input type="text" name="title" value="{{ $goods->title ?? '' }}" lay-verify="required"  class="layui-input" >
    </div>
</div>
<div class="layui-form-item layui-col-md6">
    <label for="" class="layui-form-label">商品ID</label>
    <div class="layui-input-block">
        <input type="text" name="sku" value="{{ $goods->sku ?? '' }}" lay-verify="required|number"  class="layui-input" >
    </div>
</div>
<div class="layui-form-item layui-col-md2">
    <label for="" class="layui-form-label">商品排序</label>
    <div class="layui-input-block">
        <input type="text" name="sort" value="{{ $goods->sort ?? '' }}" lay-verify="required|number"  class="layui-input" >
    </div>
</div>

<div class="layui-form-item layui-col-md6">
    <label for="" class="layui-form-label">品牌</label>
    <div class="layui-input-block">
        <select name="brand" xm-select="brand" xm-select-radio xm-select-search="">
            @foreach ($brands as $brand)
                <option value="{{$brand['id'] ?? 0}}" {{(isset($goods) && $goods->brand == $brand['id']) ? 'selected' : ''}}>{{$brand['name'] ?? ''}}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item layui-col-md6">
    <label for="" class="layui-form-label">产地</label>
    <div class="layui-input-block">
        <select name="origin" xm-select="origin" xm-select-radio xm-select-search="">
            @foreach ($origins as $v)
                <option value="{{$v['id'] ?? 0}}" {{(isset($goods) && $goods->origin == $v['id']) ? 'selected' : ''}}>{{$v['name'] ?? ''}}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item layui-col-md2">
    <label for="" class="layui-form-label">规格</label>
    <div class="layui-input-block">
        <input type="text" name="norm" value="{{ $goods->norm ?? '' }}" lay-verify="required"  class="layui-input" placeholder="规格数量" >
        <select name="norm_unit" xm-select="norm_unit" xm-select-radio xm-select-search="">
            @foreach ($norms as $v)
                <option value="{{$v['id'] ?? 0}}" {{(isset($goods) && $goods->norm_unit == $v['id']) ? 'selected' : ''}}>{{$v['name'] ?? ''}}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item layui-col-md6">
    <label for="" class="layui-form-label">功效</label>
    <div class="layui-input-block">
            @foreach ($effects as $v)
                <input type="checkbox" value="{{$v['id'] ?? 0}}"  name="effect[]" {{(isset($goodeffects) && in_array($v['id'],$goodeffects) ) ? 'checked' : ''}}  title="{{$v['name'] ?? ''}}">
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item layui-col-md2">
    <label for="" class="layui-form-label">销售价格(元)</label>
    <div class="layui-input-block">
        <input type="text" name="price" value="{{ $goods->price ?? '' }}" lay-verify="required|number"  class="layui-input" >
    </div>
</div>

<div class="layui-form-item layui-col-md2">
    <label for="" class="layui-form-label">商品重量(g)</label>
    <div class="layui-input-block">
        <input type="text" name="weight" value="{{ $goods->weight ?? '' }}" lay-verify="required|number"  class="layui-input" >
    </div>
</div>


    </div>
</fieldset>
{{--属性设置--}}
<fieldset class="layui-elem-field">
    <legend>属性信息</legend>
    <div class="layui-field-box">
        <div class="layui-form-item layui-col-md3">
            <label for="" class="layui-form-label">是否参与会员价</label>
            <div class="layui-input-block">
                @foreach ( App\models\Goods::IS_SALE as $key=>$value)
                    <input type="radio" name="is_sale" value="{{$key ?? 0}}" title="{{$value ?? 0}}"  {{(isset($goods) && $goods->is_sale == $key) ? 'checked' : ''}} >
                @endforeach
            </div>
        </div>

        <div class="layui-form-item layui-col-md3">
            <label for="" class="layui-form-label">是否可用优惠券</label>
            <div class="layui-input-block">
                @foreach ( App\models\Goods::IS_COUPON as $key=>$value)
                    <input type="radio" name="is_coupon" value="{{$key ?? 0}}" title="{{$value ?? 0}}"   {{(isset($goods) && $goods->is_coupon == $key) ? 'checked' : ''}} >
                @endforeach
            </div>
        </div>

        <div class="layui-form-item layui-col-md3">
            <label for="" class="layui-form-label">是否支持余额支付</label>
            <div class="layui-input-block">
                @foreach ( App\models\Goods::IS_PAY_BALANCE as $key=>$value)
                    <input type="radio" name="is_pay_balance" value="{{$key ?? 0}}" title="{{$value ?? 0}}"  {{(isset($goods) && $goods->is_pay_balance == $key) ? 'checked' : ''}} >
                @endforeach
            </div>
        </div>
    </div>
</fieldset>
{{--素材信息--}}

<fieldset class="layui-elem-field">
    <legend>素材信息</legend>
    <div class="layui-field-box">
        <div class="layui-form-item layui-col-md12">
            <label for="" class="layui-form-label">banner图</label>
            <div class="layui-input-block">

                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="uploadBanner">多图片上传</button><input class="layui-upload-file" type="file" accept="undefined" name="file" multiple="">
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" id="uploadBanner-imgs">
                        @if(isset($goods->banner))
                        @foreach(json_decode($goods->banner) as $key=>$value)
                                <div class="layui-inline" data="{{$key}}">
                                    <img src="{{$value}}" class="banner" width="50px" height="50px" id="{{$key}}"><br>
                                    <p style="width: 50px" class="clearbanner layui-btn layui-btn-green layui-btn-xs"  id="{{$key}}" >移除</p>
                                    <input type="hidden" name="banner[]" value="{{$value}}"  >
                                </div>

                        @endforeach
                        @endif
                        </div>
                    </blockquote>


                </div>
            </div>
        </div>
        <div class="layui-form-item layui-col-md12">
            <label for="" class="layui-form-label">详情信息</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea layui-hide" name="description"  lay-verify="description" id="description">{{html_entity_decode($goods->description ?? '') }}</textarea>
            </div>
        </div>
    </div>
</fieldset>

<div class="layui-form-item">
    <div class="layui-input-block">
        {{isset($goods) ? method_field('PUT') : ''}}
        {{csrf_field()}}
        <a  class="layui-btn" href="/admin/goods/1/list" >取消</a>
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="layui-form-submit" >保存</button>
    </div>
</div>